/*
 * St_Login_View.java
 *
 * Created on 2009年2月23日, 下午11:06
 */

package view;

import model.Stu_Login_Model;
import ucm.BeginSign_UC;
import ucm.SignIn_UC;

/**
 *
 * @author  马凯
 */
public class St_Login_View extends javax.swing.JFrame {
    private static St_Login_View slv;
    private String sub_ID;
    /** Creates new form St_Login_View */
    public St_Login_View() {
        initComponents();
        this.setLocationRelativeTo(null);
    }
    
    public static St_Login_View getInstance(SignIn_UC suc){
        if(slv==null){
            slv = new St_Login_View();
            slv.sub_ID = suc.getStatusModel().getLesson_ID();
        }
        return slv;
    }
    
    public Stu_Login_Model getStuModel(){
        Stu_Login_Model slm = new Stu_Login_Model();
        slm.setCid_TF(cid_TF);
        slm.setEnd_Bu(end_Bu);
        slm.setExit_Bu(exit_Bu);
        slm.setName_TF(name_TF);
        slm.setStu_TF(stu_TF);
        slm.setSub_ID(sub_ID);
        slm.setAttend_TF(attend_TF);
        return slm;
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cid_TF = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        name_La = new javax.swing.JLabel();
        name_TF = new javax.swing.JTextField();
        stu_La = new javax.swing.JLabel();
        stu_TF = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        end_Bu = new javax.swing.JButton();
        exit_Bu = new javax.swing.JButton();
        attend_La = new javax.swing.JLabel();
        attend_TF = new javax.swing.JTextField();
        MenuBar = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ISC_SING IN");

        cid_TF.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cid_TFKeyPressed(evt);
            }
        });

        name_La.setText("Name:");

        stu_La.setText("Student ID:");

        end_Bu.setText("End");

        exit_Bu.setText("Exit");

        attend_La.setText("Num:");

        attend_TF.setEditable(false);

        jMenu1.setText("File");
        MenuBar.add(jMenu1);

        jMenu2.setText("Edit");
        MenuBar.add(jMenu2);

        setJMenuBar(MenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cid_TF, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(296, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(264, Short.MAX_VALUE)
                .addComponent(end_Bu, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(exit_Bu)
                .addContainerGap())
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(name_La, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(attend_La))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(attend_TF)
                    .addComponent(name_TF, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(stu_La)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(stu_TF, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cid_TF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(stu_La)
                    .addComponent(stu_TF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(name_La)
                    .addComponent(name_TF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(attend_La)
                    .addComponent(attend_TF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 121, Short.MAX_VALUE)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(exit_Bu)
                    .addComponent(end_Bu))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cid_TFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cid_TFKeyPressed
        if(evt.getKeyCode()==13||evt.getKeyCode()==10){
            BeginSign_UC.getInstance(this).run();
        }
    }//GEN-LAST:event_cid_TFKeyPressed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new St_Login_View().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar MenuBar;
    private javax.swing.JLabel attend_La;
    private javax.swing.JTextField attend_TF;
    private javax.swing.JTextField cid_TF;
    private javax.swing.JButton end_Bu;
    private javax.swing.JButton exit_Bu;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JLabel name_La;
    private javax.swing.JTextField name_TF;
    private javax.swing.JLabel stu_La;
    private javax.swing.JTextField stu_TF;
    // End of variables declaration//GEN-END:variables
    
}
